<?php

namespace admin\models;

use Yii;

/**
 * This is the model class for table "mm_user_comment".
 *
 * @property integer $mc_id
 * @property integer $mu_id
 * @property integer $ma_id
 * @property string $mc_detail
 *
 * @property Info $mu
 *
 * @property Admin $ma
 */
class UserComment extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'mm_user_comment';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['mc_detail'],'required'],
            [['mu_id', 'ma_id'], 'integer'],
            [['mc_detail'], 'string', 'max' => 100],
            [['mu_id'], 'exist', 'skipOnError' => true, 'targetClass' => UserInfo::className(), 'targetAttribute' => ['mu_id' => 'mi_id']],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'mc_id' => '映象id',
            'mu_id' => '用户id',
            'ma_id' => '管理员id',
            'mc_detail' => '印象',
        ];
    }

    /**
     * @return \yii\db\ActiveQuery
     */
    public function getMu()
    {
        return $this->hasOne(UserInfo::className(), ['mi_id' => 'mu_id']);
    }

    public function getMa()
    {
        return $this->hasOne(Admin::className(), ['ma_id' => 'ma_id']);
    }
}
